def display_poem():
    """正确对齐标题、作者和诗句，使它们居中对齐"""
    title = "白槐花开"
    author = "作者：张军"
    verses = [
        "雨霁扶筇趁煦阳，蝶蜂引我醉槐香。",
        "万花莹玉枝桠挂，千树芳姿陌野藏。",
        "久阔故园怀父老，静观素蕊恋家乡。",
        "亲尝一串忆童趣，更有佳吟诗胜唐。"
    ]
    
    # 收集所有文本元素，计算最长长度
    all_texts = [title, author] + verses
    max_length = max(len(text) for text in all_texts)
    display_width = max_length  # 也可以加边距，比如max_length + 4
    
    # 打印分隔线和标题
    print("-" * display_width)
    print(title.center(display_width))
    print(author.center(display_width))
    print("-" * display_width)
    
    # 打印每句诗，居中对齐
    for verse in verses:
        print(verse.center(display_width))
    print("-" * display_width)

if __name__ == "__main__":
    display_poem()
    
    while True:
        choice = input("\n是否要再次查看诗句？(y/n): ").lower()
        if choice == 'y':
            display_poem()
        elif choice == 'n':
            print("感谢阅读，再见！")
            break
        else:
            print("请输入 'y' 或 'n'")